<%--
 *  File:    AdditionalCaptionEdit.jsp
 *  @Author: Fekin Dai
 *  Date:    2009/10/29
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "COM";
	String privilegeCode = "Z0835";
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>AdditionalCaptionEdit</title>
<PageFlow:CheckPageFlow pageName="p_additionalcaption"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector details = (Vector)pageContext.getAttribute("details");
  	if(details == null)
  	{
  		details = new Vector();
  	}
    int totalsize  = details.size();

     HashMap datacategoryinfo = (HashMap)pageContext.getAttribute("datacategoryinfo");
  if(datacategoryinfo == null)
  {
    datacategoryinfo = new HashMap();
  }
%>

<script language="JavaScript" >
var idx = 0;
function page_go(){
 	 cform.action = "ZylAdditionalCaptionEdit.jsp?<%= OvalTools.randomURL() %>";
 	 cform.target = "_self";
 	 isRunning = true;
 	 cform.submit();
}
function p_change(){
 	 cform.action = "ZylAdditionalCaptionEdit.jsp?<%= OvalTools.randomURL() %>";
 	 cform.target = "_self";
 	 isRunning = true;
 	 cform.submit();
}
function page_save(){
	 //for(var i = 0; i <<%=totalsize%>; i++){
	 //	if(cform['isdict'+i].value=="Y"){
	 //		if(isEmpty(cform['dicttype'+i].value)){
	 //			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_DicType")) %>");
	 //			return;
	 // 		}
	 //	}
	 //}
	 if(!checkForm(document.cform))return;
	 emptyToNull(cform);
	 formatCheckBox(cform);
	 cform.actionname.value = "save";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}
 function set_orgNameByPopWindow(id,code,name){

     idObj=document.getElementById("zmylprodgroupid"+idx);
    nameObj=document.getElementById("productgroupname"+idx);
    captionname=document.getElementById("captionname"+idx);
	nameObj.value=name;
	captionname.value=name;
	idObj.value=id;
    document.getElementById("captionname"+idx).command="notnull";
}
function popWindowsContactProd(n_idx){

     idx=n_idx;
    if(popwindow!=null) popwindow.close();
 	popwindow = window.open("../masterdata/ogm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>&datacategory=<custom:write  property="datacategory"/>", "newwindow", "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes")

}

function cleanid(n_idx){
    idObj = document.getElementById("zmylprodgroupid"+n_idx);
    nameObj = document.getElementById("productgroupname"+n_idx);
    captionname = document.getElementById("captionname"+n_idx);

    if (isEmpty(nameObj.value)){
        idObj.value=" ";
        captionname.value=" ";
    }
    document.getElementById("captionname"+n_idx).command="";
}

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_additionalcaption">
<input type="hidden" name="actionname">
<input type="hidden" name="numrows" value="<%= details.size() %>">

<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
		<td><%= label.getLabelName("L_Type") + label.getLabelName("L_Colon") %>
			<custom:selectdic property="datacategory" dictType="ZylDataCategory" onchange="p_change()" />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="javascript:page_go()"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a>
		</td>
	</tr>
</table>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
          <% if ("Y".equals(datacategoryinfo.get("description"))){%>
           <td width="5%" class="title_center"><%= label.getLabelName("L_AdditionalField") %></td>
          <td class="title_center" width="5%"><%= label.getLabelName("L_SYSColumnType") %></td>
          <td class="title_center" width="9%"><%= label.getLabelName("L_IsVisible") %></td>
          <td class="title_center" width="9%"><%= label.getLabelName("L_CaptionName") %>&nbsp;<span class='red'>*</span></td>
          <td class="title_center" width="15%"><%= label.getLabelName("L_IsDicData") %></td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_DicType") %></td>
          <td class="title_center" width="10%"><%= label.getLabelName("L_ProductGroup") %><%= label.getLabelName("L_Name") %></td>

          <%}else{%>
           <td width="15%" class="title_center"><%= label.getLabelName("L_AdditionalField") %></td>
          <td class="title_center" width="15%"><%= label.getLabelName("L_SYSColumnType") %></td>
          <td class="title_center" width="20%"><%= label.getLabelName("L_IsVisible") %></td>
          <td class="title_center" width="20%"><%= label.getLabelName("L_CaptionName") %></td>
          <td class="title_center" width="15%"><%= label.getLabelName("L_IsDicData") %></td>
          <td class="title_center" width="25%"><%= label.getLabelName("L_DicType") %></td>
          <%}%>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%= details %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
            	<td class="title_center">
            		<custom:write name="onerow" property="columnname"  nbsp="true"/>
            		<input type="hidden" name="attrname<%=idx%>" value="<custom:write name="onerow" property="columnname"/>"/>
            	</td>
            	<td class="title_center">
            		<custom:write name="onerow" property="value" dictType="AttrType" nbsp="true"/>
            		<input type="hidden" name="attrtype<%=idx%>" value="<custom:write name="onerow" property="value"/>"/>
            	</td>
				<td class="title_center">
					<custom:checkbox name="onerow" property="inuse" style="border:0" checkFlag="Y/N" colIndex="<%= idx %>"/>
				</td>
				<% if ("Y".equals(datacategoryinfo.get("description"))){%>    
				  <td class="title_center">
				    <custom:text name="onerow" property="captionname" size="20" colIndex="<%= idx %>" label="L_CaptionName"/>
     		      </td>
     		    <%}else{ %>
     		      <td class="title_center">
				    <custom:text name="onerow" property="captionname" size="20" colIndex="<%= idx %>"/>
     		      </td>
     		    <%} %>
            	<td class="title_center">
            		<custom:checkbox name="onerow" property="isdict" style="border:0" checkFlag="Y/N" colIndex="<%= idx %>"/>
            	</td>
            	<td class="title_center">
            		<custom:text name="onerow" property="dicttype" size="20" colIndex="<%= idx %>" label="L_DicType"/>
            		<custom:hidden name="onerow" property="additionalcaptionid" colIndex="<%= idx %>"/>
            	</td>
                <% if ("Y".equals(datacategoryinfo.get("description"))){%>
                <td>
           		<custom:hidden name="onerow" property="prodgroupcode"  />
                <input type="text" name="productgroupname<%= idx %>"  value='<custom:write name="onerow" property="productgroupname" />' onchange="cleanid(<%= idx %>)"/>
                <a onclick='popWindowsContactProd(<%= idx %>)'>  <custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                <custom:hidden property="zmylprodgroupid" colIndex="<%= idx %>"/></td>
               <%}%>
              </tr>
     	 </logic:iterate>
     <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
        <tr>
          <td class="td_center">
          <%if(details.size()> 0){ %>
		  	<a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="save.gif" border="0" style="width:60"/></a>
		  <%} %>
		  </td>
        </tr>
     </table>
</table>
</form>
</body>
</html>